{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "245a954a",
   "metadata": {},
   "source": [
    "# Dataherald\n",
    "\n",
    "This notebook goes over how to use the dataherald component.\n",
    "\n",
    "First, you need to set up your Dataherald account and get your API KEY:\n",
    "\n",
    "1. Go to dataherald and sign up [here](https://www.dataherald.com/)\n",
    "2. Once you are logged in your Admin Console, create an API KEY\n",
    "3. pip install dataherald\n",
    "\n",
    "Then we will need to set some environment variables:\n",
    "1. Save your API KEY into DATAHERALD_API_KEY env variable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "961b3689",
   "metadata": {
    "vscode": {
     "languageId": "shellscript"
    }
   },
   "outputs": [],
   "source": [
    "pip install dataherald\n",
    "%pip install --upgrade --quiet langchain-community"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "34bb5968",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "\n",
    "os.environ[\"DATAHERALD_API_KEY\"] = \"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ac4910f8",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_community.utilities.dataherald import DataheraldAPIWrapper"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "84b8f773",
   "metadata": {},
   "outputs": [],
   "source": [
    "dataherald = DataheraldAPIWrapper(db_connection_id=\"65fb766367dd22c99ce1a12d\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "068991a6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'select COUNT(*) from employees'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataherald.run(\"How many employees are in the company?\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "vscode": {
   "interpreter": {
    "hash": "53f3bc57609c7a84333bb558594977aa5b4026b1d6070b93987956689e367341"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
